package com.atstudy.headline.web.admin.controller.statistics;

import com.atstudy.headline.entity.SystemOperationDaily;
import com.atstudy.headline.result.Result;
import com.atstudy.headline.web.admin.service.SystemOperationDailyService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin/systemOperationDaily")
public class systemOperationDailyController {

    @Autowired
    private SystemOperationDailyService systemOperationDailyService;

    /**
     * 分页查询用户行为数据
     * @param current 当前页码
     * @param size 每页大小
     * @param systemOperationDaily 查询条件
     * @return 分页结果
     */
    @GetMapping("/daily/page")
    public Result<IPage<SystemOperationDaily>> pageUserBehaviorDaily(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "6") Integer size,
            SystemOperationDaily systemOperationDaily) {
        Page<SystemOperationDaily> page = new Page<>(current, size);
        LambdaQueryWrapper<SystemOperationDaily> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(systemOperationDaily.getDau() != null, SystemOperationDaily::getDau, systemOperationDaily.getDau());
        queryWrapper.like(systemOperationDaily.getMau() != null, SystemOperationDaily::getMau, systemOperationDaily.getMau());
        IPage<SystemOperationDaily> systemOperationDailyIPage = systemOperationDailyService.page(page, queryWrapper);
        return Result.ok(systemOperationDailyIPage);
    }
}
